<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/10/17
 * Time: 9:05
 */
namespace app\api\controller;
use think\Db;
use think\Request;
use app\api\model\Tour as Tours;
class Tour extends Nocommon
{
    /*
     * 景点列表接口
     */
    public function tourList()
    {
        if(Request::instance()->isPost()){
            $type = input('type','1','trim');
            $sort = input('sort','1','trim');
            $content = input('content','','trim');

            $where['tour_name'] = array('like','%' . $content . '%');

            $page = $this->p();
            $tour = new Tours();
            //按销量排序
            if($type==1 && $sort==1){

                $tours = $tour->tour_list($where,$page,1);

            }
            if($type==2 && $sort==1){
                $where['type'] = array('like','%'. 1 .'%');
                $tours = $tour->tour_list($where,$page,1);
            }
            if($type==3 && $sort==1){
                $where['type'] = array('like','%'. 2 .'%');
                $tours = $tour->tour_list($where,$page,1);
            }
            if($type==4 && $sort==1){
                $where['type'] = array('like','%'. 3 .'%');
                $tours = $tour->tour_list($where,$page,1);

            }
            if($type==5 && $sort==1){
                $where['type'] = array('like','%'. 4 .'%');
                $tours = $tour->tour_list($where,$page,1);
            }

            //价格排序
            if($type==1 && $sort==2)
            {
                $tours = $tour->tour_list($where,$page,2);
            }
            if($type==2 && $sort==2){
                $where['type'] = array('like','%'. 1 .'%');
                $tours = $tour->tour_list($where,$page,2);
            }
            if($type==3 && $sort==2){
                $where['type'] = array('like','%'. 2 .'%');
                $tours = $tour->tour_list($where,$page,2);
            }
            if($type==4 && $sort==2){
                $where['type'] = array('like','%'. 3 .'%');
                $tours = $tour->tour_list($where,$page,2);
            }
            if($type==5 && $sort==2){
                $where['type'] = array('like','%'. 4 .'%');
                $tours = $tour->tour_list($where,$page,2);
            }

            //安好评排序
            if($type==1 && $sort==3)
            {
                $tours = $tour->tour_list($where,$page,3);
            }
            if($type==2 && $sort==3){
                $where['type'] = array('like','%'. 1 .'%');
                $tours = $tour->tour_list($where,$page,3);
            }
            if($type==3 && $sort==3){
                $where['type'] = array('like','%'. 2 .'%');
                $tours = $tour->tour_list($where,$page,3);
            }
            if($type==4 && $sort==3){
                $where['type'] = array('like','%'. 3 .'%');
                $tours = $tour->tour_list($where,$page,3);
            }
            if($type==5 && $sort==3){
                $where['type'] = array('like','%'. 4 .'%');
                $tours = $tour->tour_list($where,$page,3);
            }
            $this->apiReturn('200','成功',$tours);
        }
    }
    /**
     * [getTourInfo 获取景点的详情]
     * @Author   kendy
     * @DateTime 2019-10-28T16:06:35+0800
     * @return   [type]                   [description]
     */
    public function getTourInfo()
    {
         if(Request::instance()->isPost()){  
          $tour = new Tours();
          $tour_id = input('post.tour_id/d');
          $page = $this->p();    
          $limit = input('post.limit/d');
          if(empty($tour_id))  return $this->apiReturn('400','景点id为空',0);
          $tourInfo = $tour->getTourInfo($tour_id);  
          return $this->apiReturn('200','成功',$tourInfo);
        }

    }

}